package cn.itcast.bos.service.base.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.dao.base.StandardRepository;
import cn.itcast.bos.domain.base.Standard;
import cn.itcast.bos.service.base.StandardService;

@Service
@Transactional
public class StandardServiceImpl implements StandardService {

	// 注入DAO
	@Autowired
	private StandardRepository standardRepository;

	@Override
	public void save(Standard standard) {
		standardRepository.save(standard);
	}

	//value：缓存位置名称，不能为空，如果使用EHCache，就是ehcache.xml中声明的cache的name
	//key：缓存的key，默认为空，既表示使用方法的参数类型及参数值作为key，支持SpEL
	
	@Override
	//@Cacheable(value="standard",key="#pageable.pageNumber+'_'+#pageable.pageSize")
	public Page<Standard> findPageData(Pageable pageable) {
		return standardRepository.findAll(pageable);
	}

	@Override
	//@Cacheable(value="standard")
	public List<Standard> findAll() {
		return standardRepository.findAll();
	}

}
